<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html>
<html>
  <head> 
    <title>订阅查询</title>  
    <jsp:include page="/include.jsp"/>
    <script type="text/javascript">
    //详细
    function doDetail(userId,reportId){
    	window.top.$('<div/>').dialog({
			href:'${pageContext.request.contextPath}/subQuery/subQueryAction!getSubscribleInfo.action?userId='+userId+'&reportId='+reportId,
			top:($(window).height()-250)*0.5,
			left:($(window).width()-300)*0.5,
			width:660,
			modal:true,
			title:'订阅详细信息',	
			buttons:[{
				text:'关 闭',
				iconCls:'', 
				handler:function(){
					var d=window.top.$(this).closest('.window-body');
					d.dialog('destroy'); 
				}
			}],
			onClose:function(){
				window.top.$(this).dialog('destroy');
			}
		});
    }
    
    
    //执行查询
    function doQuery(){   
    	var dataGridOptions=$('#table_datagrid').datagrid('options');
		dataGridOptions.queryParams=serializeObject($('#query_form'));
		$('#table_datagrid').datagrid(dataGridOptions);  
		$('#table_datagrid').datagrid('load');
    }

    //重置查询条件   
    function doReset(){
    	$('#query_form').form('reset');
    	$('#requiresrc').combobox('setValue',null);
    	$('#reportType').combobox('setValue',null);
    }
    //页面加载完后响应 onReady
	$(function() {
		//doQuery();
		//初始化主列表
		$('#table_datagrid').datagrid({
			url:'${pageContext.request.contextPath}/subQuery/subQueryAction!getAllReportSubDefineForPage.action',
			queryParams:serializeObject($('#query_form')),
			fit:true,
			border:false,
			fitColumns:true,
			striped:true,
			pagination:true,
			pageList:[10,20,30],
			rownumbers:false,
			singleSelect:true,                   
			sortName:'createTime',
			sortOrder:'desc',
			columns:[[{
				field:'reportName',
				title:'报告名称',
				width:150,
			    formatter:function(reportName,rowData,rowIndex){ 
				//	return '<a title="'+reportName+'" onclick="doDetail(\''+rowData.userId+'\',\''+rowData.reportId+'\')"  style="color:#398ece;cursor:pointer;text-decoration:underline">'+reportName+'</a>';
					return '<div  onmouseover="onMouseOverName(this)"  onmouseout="onMouseOutName(this)" onclick="doDetail(\''+rowData.userId+'\',\''+rowData.reportId+'\')"  style="color:#2b76b7;cursor:pointer;width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;" title="'+reportName+'">'+reportName+'</div>';
				}},{
				field:'reportTypeName',
				title:'报告类型',
				width:150,
				sortable:true
			   },{
				field:'requiresrcName',
				title:'信息来源',
				width:150,
				sortable:true
			},{
				field:'subscribleName',
				title:'订阅人',
				width:150,
				sortable:true
			},{
				field:'createTime',
				title:'订阅时间',
				width:150,
				sortable:true
			}]], 
		});  
		//查询按纽绑定事件
		$('#btnQuery').bind('click',doQuery);
		//重置按纽绑定事件
		$('#btnReset').bind('click',doReset);
		
		//初始化下拉树
// 		$('#userId').combotree({  
// 		    url: '${pageContext.request.contextPath}/infopublish/infoPublishAction!getUserTreeInfo.action',  
// 		    parentField : 'pid',
// 		    required: false  
// 		}); 
		
		//初始化订阅人下拉列表  
		$('#userId').combogrid({     
	        panelWidth:450,  
	        idField:'userid', //ID字段  
	        textField:'username', //显示的字段  
	        url:"${pageContext.request.contextPath}/problemmgr/problemAction!showHandler.action",  
	        fitColumns: true,  
	        striped: true,  
	        editable:false,
	        pagination : true,//是否分页  
	        rownumbers:true,//序号  
	        collapsible:false,//是否可折叠的  
	        fit: true,//自动大小  
	        pageSize: 10,//每页显示的记录条数，默认为10  
	        pageList:[10,20,30],//可以设置每页记录条数的列表  
	        method:'post',  
	        columns:[[{field:'userid',title:'用户ID',width:70,align:'center',sortable:true},				  
					  {field:'username',title:'用户名称',width:75,align:'center',sortable:true}		 
					]],
			toolbar:'#tb'
	    }); 
		
		//初始化急报快报类型下拉框
		$('#reportType').combobox({  
		    url:'${pageContext.request.contextPath}/infopublish/infoPublishAction!getDictionaryInfo.action?codeType=reportType&tableName=TD_SPEED_REPORT_DEFINE',  
		    valueField:'codeValue',
			textField:'codeName',
			panelHeight:'auto',
  	 		editable:false,
  	 		onLoadSuccess:function(){
  				$('#reportType').combobox('setValue',null);
  			}
		});  
		
		//初始化信息来源下拉框
		$('#requiresrc').combobox({  
			url:ctx+'/basemgr/kqiManagerAction!getDic.action?dictType=requireSrc&tableName=TD_SPEED_REPORT_DEFINE&&excludeValues=4&&list=list',   
		    valueField:'codeValue',
			textField:'codeName',
			panelHeight:'auto',
  	 		editable:false,
  	 		onLoadSuccess:function(){
  				$('#requiresrc').combobox('setValue',null);
  			}
		}); 
	});
    
	function queryUser()
  	{
   		var username=$('#query_userName').val();	
   		var query={username:username}; //把查询条件拼接成JSON
   		var grid=$("#userId").combogrid('grid');   
   		$(grid).datagrid('options').queryParams=query; //把查询条件赋值给datagrid内部变量
   		$(grid).datagrid('load');
   	}

	function resetQuery()
  	{
		$('#query_userName').val('');
   	}
</script>
<body class="easyui-layout">  
	<form id="query_form" method="post">
	    <div data-options="region:'north'" style="height:80px;border-bottom:none;border-top:none;">
	    	<table border="0" cellpadding="0" cellspacing="0" height="100%"  width="100%" >
	    		<tr>
		    		<td style="text-align:right;width:10%;" nowrap="nowrap">
		    			<label>订阅人：&nbsp;</label>
		    		</td>
					<td style="text-align:left;width:15%;" nowrap="nowrap">
	    				<input type="text" id="userId" style="height:22px;"  name="userId" />
					</td>
					<td style="text-align:right;width:10%;" nowrap="nowrap">
						<label>名称：&nbsp;</label>
					</td>
					<td style="text-align:left;width:15%;" nowrap="nowrap">
	    				<input type="text" id="reportName" name="reportName" class="easyui-validatebox"  validType="specialCharFilter('reportName')"/>
					</td> 
					<td style="text-align:right;width:10%;" nowrap="nowrap">
						<label>信息来源 ：&nbsp;</label>
					</td>
					<td style="text-align:left;width:15%;" nowrap="nowrap">
	    				<input id="requiresrc" class="easyui-combobox"  name="requiresrc"   panelHeight="auto"/>
					</td>
					<td style="text-align:right;width:10%;" nowrap="nowrap">
						<label>类型 ：&nbsp;</label>
					</td>
					<td style="text-align:left;width:15%;padding-right:50px" nowrap="nowrap">
	    				<input id="reportType" class="easyui-combobox"  name="reportType"  panelHeight="auto"/>
					</td>
	    		</tr>
	    		<tr>
	    		    <td style="width:10%;text-align:right;" nowrap="nowrap">
					</td>
					<td style="width:15%;text-align:left;" nowrap="nowrap">
					</td>
		    		<td style="width:10%;text-align:right;" nowrap="nowrap">
					</td>
					<td style="width:15%;text-align:left;" nowrap="nowrap">
					</td>
					<td style="width:10%;text-align:right;" nowrap="nowrap">
					</td>
					<td style="width:15%;text-align:left;" nowrap="nowrap">
					</td>
	    			<td colspan="2" style="width:25%;text-align:right;" nowrap="nowrap">	   
			    		<input type="button" id="btnQuery" name="" value="查 询" style="cursor:pointer;background-image: url('${pageContext.request.contextPath}/images/login/search.png');background-repeat: no-repeat;width:67px;height:23px;padding-left:12px;border:none;color:white;font-family:微软雅黑;"/>	
			    		<input type="button" id="btnReset" name="" value="重 置" style="cursor:pointer;background-image: url('${pageContext.request.contextPath}/images/login/reset.png');background-repeat: no-repeat;width:67px;height:23px;padding-left:12px;border:none;color:white;font-family:微软雅黑;margin-right:50px"/>				
	    			</td>
	    		</tr>
			</table>
	    </div>  
	    <div data-options="region:'center'">  
	        <table id="table_datagrid"> 
			</table>
	    </div>  
	    
	    <div id="tb" style="padding:5px;height:auto">   
		    <div>  
		               用户名称 : <input id="query_userName" type="text" class="easyui-validatebox" style="width:150px" >  
		        <input type="button" id="btnQuery" onclick="queryUser()" value="查 询" style="cursor:pointer;background-image: url('${pageContext.request.contextPath}/images/login/search.png');background-repeat: no-repeat;width:67px;height:23px;padding-left:12px;border:none;color:white;font-family:微软雅黑;"/>	
				<input type="button" id="btnReset" onclick="resetQuery()" value="重 置" style="cursor:pointer;background-image: url('${pageContext.request.contextPath}/images/login/reset.png');background-repeat: no-repeat;width:67px;height:23px;padding-left:12px;border:none;color:white;font-family:微软雅黑;margin-right:55px"/> 
		    </div>  
		</div>
    </form>
</body>  
</html>